import React, { Component } from 'react'
import TabControll from './TabControll'

class App extends Component {
  constructor() {
    super()
  
    this.state = {
      tabTitle: ['推荐', '新品', '精选'],
      tabsIndex: 0
    }
  }

  getTabsIndex(index) {
    this.setState({tabsIndex: index})
  }

  render() {
    const { tabTitle, tabsIndex } = this.state
    return (
      <div>
        <TabControll title={tabTitle} getTabsIndex={index => this.getTabsIndex(index)} />
        <h2>{ tabTitle[tabsIndex]}</h2>
      </div>
    )
  }
}

export default App